package com.example.experiment05.repository;

import com.example.experiment05.dto.UserAddress02;
import com.example.experiment05.entity.Address;
import com.example.experiment05.mapper.UserAddress01RowMapper;
import com.example.experiment05.mapper.UserAddress02RowMapper;
import org.springframework.data.jdbc.repository.query.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface AddressRepository extends CrudRepository<Address, Long> {
    @Query("select * from address a where a.user_id=:uid")
    List<Address> findUserAdressList(long uid);

    @Query(value = "select * from address a join user u on u.id = a.user_id where a.id=:aid",
            rowMapperClass = UserAddress02RowMapper.class)
    UserAddress02 findAddressUser2(long aid);
}
